<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            position: absolute;
            width: 80px;
            height: 80px;
            background: salmon;
            border-radius: 50%;
        }
    </style>
</head>
<body>
    <div class="box">

    </div>
    <script>
        var box = document.querySelector('.box');
        box.onmousedown = function(){
            window.onmousemove = function(e){
                console.log(box.offsetWidth);
                e = e || window.event;
                var x = e.clientX-box.offsetWidth/2;
                var y = e.clientY-box.offsetHeight/2;
                
                box.style.left = x + 'px';
                box.style.top = y + 'px';
            }
        }
        window.onmouseup = function (){
            window.onmousemove = null;
        }
    </script>
</body>
</html>